package org.jpro.common.http;

import org.jpro.exception.ExceptionCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * <P>功能描述 : 接受参数标准格式 </P>
 * <P>File name : RequestVO </P>
 * <P>Author : 王泽浩 </P>
 * <P>E-Mail : 1028625100@qq.com </P>
 * <P>Date : 2017/1/20 下午2:18</P>
 */
@Getter
@Setter
@ToString
public class RequestVO<T> {
    private static final Logger LOGGER = LoggerFactory.getLogger(RequestVO.class);

    /**
     * 状态码 @{@link org.jpro.exception.ExceptionCode }
     * 其余数值表示出现错误，该值对应ExceptionCode中定义的异常码
     */
    private int code;

    /**
     * 状态码提示
     */
    private String msg;

    /**
     * 数据信息
     */
    private T data;

    public RequestVO(ExceptionCode exceptionCode) {
        this.code = exceptionCode.getCode();
        this.msg = exceptionCode.getMsg();
    }

    public RequestVO(ExceptionCode exceptionCode, T data) {
        this.code = exceptionCode.getCode();
        this.msg = exceptionCode.getMsg();
        this.data = data;
    }

    public RequestVO(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public RequestVO(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
}
